{include file="admin/top.php" subject='stocks'}
{include file="stocks/top.php" subject='stocks'}
<div id="content">

    <div id="boxquery">
    <form method="get">
     <input type="hidden" name="m" value="inventory" />
        <input type="hidden" name="s" value="stocks.php" />
        <input type="submit" value="查询" class="fr" onclick="orderBy('','',1)" />
         <input type="hidden" value="" id="orderby" name="orderby" />
         <input type="hidden" value="" id="ascdesc" name="ascdesc" />
        <li>仓库:&nbsp; <select id="shopid" name="shopid"><option value="">全部</option>{shops}<option value="{$shops.id}" {if $shops.id==$smarty.get.shopid}selected{/if}>{$shops.title}</option>{/shops}</select></li>
        <li><div style="line-height: 15px;float:left;">产品ID:&nbsp; </div><textarea name="productid" style="resize:horizontal;float:left;height:30px;">{$smarty.get.productid}</textarea></li>
        <li>产品关键字:&nbsp; <input id="keywords" name="keywords" type="text" size="30" value="{$smarty.get.keywords}" /><!-- onclick="select()" 
        onkeyup="context_menu_products(this, 'keywords=[title]')" onfocus="context_menu_products(this, 'keywords=[title]')"  --></li>
        <li>库存:&nbsp; <input id="lnumber" name="lnumber" type="text" size="8" value="{$smarty.get.lnumber}"/>-<input id="hnumber" name="hnumber" type="text" size="8" value="{$smarty.get.hnumber}"/>
        </li>
        <li>&nbsp;&nbsp;&nbsp;产品条码:&nbsp; <input id="barcode" name="barcode" type="text" size="15"  value="{$smarty.get.barcode}" />
        </li>
        <li>库存状态:&nbsp; <select id="shopwarningnum" name="shopwarningnum"><option value="0" {if $smarty.get.shopwarningnum== 0}selected{/if}>全部</option><option value="1" {if $smarty.get.shopwarningnum== 1}selected{/if}>库存充足</option><option value="2" {if $smarty.get.shopwarningnum== 2}selected{/if}>库存预警</option></select></li>
    </form>
    </div>

    <table width="100%" border="0" cellspacing="0" cellpadding="5" id="lister">
      <tr id="title">
        <td width="40">编号</td>
        <td>仓库</td>
        <td>产品ID</td>
        <td>产品图</td>
        <td>产品名称</td>
        <td>规格</td>
        <td>单位</td>
        <td>库存总数 &nbsp;&nbsp;<a href="javascript:;" onclick="orderBy('stocks','asc')">↑</a>&nbsp;&nbsp;&nbsp; <a href="javascript:;" onclick="orderBy('stocks','desc')">↓</a></td>
       <td> 采购在途 </td>
        <td> 预发货</td>
        <td> 微仓</td>
        <td>实际库内库存</td>                
         <td>退货在途</td> 
        <td>虚拟库存</td>
        <td>&nbsp;</td>
      </tr>
      {stocks limit=20 pager=pager  page=$segment.page path=$segment.1 order=$smarty.get.orderby ascdesc=$smarty.get.ascdesc shopid=$smarty.get.shopid productid=$smarty.get.productid keywords=$smarty.get.keywords counter=1 lnumber=$smarty.get.lnumber hnumber=$smarty.get.hnumber barcode=$smarty.get.barcode}
      <tr id="content">
        <td>{$stocks.id}</td>
        <td>{$stocks.shop}</td>
        <td>{$stocks.pid} </td>
        <td><img src="{$stocks.product_pic}" width="50" height="50"/></td>
        <td>{$stocks.product} </td>
        <td>{$stocks.spec}</td>
        <td>{$stocks.unit}</td>
        <td>{$stocks.stocks+0} {$stocks.unit}&nbsp;</td>
        <td align="center">{$stocks.purchases+0}</td>
        <td align="center">{$stocks.orders+0}</td>
        <td align="center">{$stocks.microstock_nums+0}</td>
        <td align="center">{$stocks.stocks-$stocks.orders-$stocks.microstock_nums}{if $stocks.stocks-$stocks.orders+0 <=  $stocks.shopwarningnum}<span style="color:red;"><br/>(库存预警)</span>{/if}</td>
        <td align="center">{$stocks.reback+0}</td>
        <td align="center">{$stocks.canbuyout}</td>
        <td><!-- 共({$stocks.more_stock.nums})个批次<!-- ,最近保质期为:<span style="font-weight: bold;{if $stocks.more_stock.data[0].timeend-$smarty.now<2592000}color:red{/if}">{$stocks.more_stock.data[0].timeend|date_format:"%Y-%m-%d"}</span> --></td>
      </tr>
      {/stocks}
      {if $pager->rows==0}
      <tr id="content">
        <td colspan="20">&nbsp;</td>
      </tr>
      {/if}
    </table>
    <div id="pager" class="mt10">
        {if $pager}<span class="fr"><strong>合计</strong>: 库存数量:{$stocks.counter.number+0}</span> 共{$pager->rows}条记录 第{$pager->pagecurrent}/{$pager->pages}页 {/if} 		
        {if $pager->current > 1}<a href="{url s1=1}">首页</a>{/if}
        {if $pager->current > 1}<a href="{url s1=$pager->current-1}">上页</a>{/if}
        {if $pager->current < $pager->pages}<a href="{url s1=$pager->current+1}">下页</a>{/if}
        {if $pager->current < $pager->pages}<a href="{url s1=$pager->pages}">尾页</a>{/if}
    </div>
    <br/>
    <form method="post" target="export_iframe" id="export_form" action=""><input type="hidden" value="export" name="act"/></form>
    <iframe src="" style="display:none;" id="export_iframe" name="export_iframe"></iframe>
    <div style="float:right" id="els_export">
            <a href="javascript:;" onclick="$('#export_form').submit();">导出EXCEL</a></div>
</div>
<script>
{literal}
function orderBy(o,s,no){
    $('#orderby').val(o);
    $('#ascdesc').val(s);
    if(!no){
        $('#boxquery').find('form').submit();
    }
    
}
{/literal}
</script>
{include file="admin/bottom.php"}
</body>
</html>
